package org.monitor;

import org.Panel.FaPanel;
import org.Panel.MainPanel;

import javax.swing.*;
import java.util.ArrayList;

public class PanelMonitor extends Thread {

    //窗口
    MainPanel mainPanel;

    //运行界面对象列表
    public ArrayList<FaPanel> panels = new ArrayList<>();

    //构造
    public PanelMonitor(MainPanel mainPanel) {
        this.mainPanel = mainPanel;
        panels.add(mainPanel.BasePanel);
        panels.add(mainPanel.focusedPanel);
    }

    //设置界面运行列表
    public void setPanels(FaPanel... panel1) {
        panels.clear();
        for(FaPanel panel : panel1) {
            panels.add(panel);
        }
    }

    //界面监测器运行区
    public void run() {

        while (true) {
            try {
                sleep(50);
            } catch (InterruptedException e) {
//                interrupt();
                throw new RuntimeException(e);
            }

            for(FaPanel panel : panels) {
                panel.Run();
            }
        }

    }
}
